#include<stdio.h>
#include<stdlib.h>
#include<assert.h>
#include<ctype.h>
int copy_atoi(const char* str)
{
	assert(str != NULL);
	if (*str == '\0')
	{
		return 0;
	}
	while (isspace(*str))
	{
		str++;
	}
	int flag = 1;
	while (*str == '+' || *str == '-')
	{
		if (*str == '+')
		{
			flag *= 1;
			str++;
		}
		else 
		{
			flag *= -1;
			str++;
		}
	}
	long long int ret = 0;
	while (*str != '\0')
	{
		if (isdigit(*str))
		{
			ret = ret * 10 + (*str - '0') * flag;
		}
		else
		{
			return (int)ret;
		}
		str++;
	}
	return (int)ret;
}
int main()
{
	int r = copy_atoi("     -+++++-123");
	printf("%d ", r);
	return 0;
}